#pragma once

#include <atomic>
#include <stdint.h>

#include "utils/Singleton.h"

// UUID Generator based on counter and local ip.
class clsUUIDGenerator: public Certain::clsSingleton<clsUUIDGenerator>
{
private:
    static const uint64_t kUpper;

    uint64_t m_iUIP;
    uint64_t m_iCurrTimeUS;
    std::atomic<uint64_t> m_iCount{0};

public:
    // Gets local ip and current time in US unit.
    // The counter would be initialized with (timestamp % kUpper).
    void Init();

    // UUID is generated by ${counter}${local_ip}.
    uint64_t GetUUID();
};
